
<?php
include("./PDO/PdoConnect.php"); //On inclut la connexion à la base de données.
include("./PDO/PdoReunion.php"); //On inclut les fonctions PDO (create / update etc...)
require("./class/Reunion.php"); //On requiere le fichier.

if (isset($_GET['action']))
{
	$action = $_GET['action'];
}

switch ($action)
{
	case "ajouter": //On inclut la page pour ajouter une situation.
            include("./page/reunion/ajouter.php");
            break;
	case "traitement_ajout": //On inclut la page qui insère la situation en base.
            $reunion = new Reunion();        
            $reunion->setNomReunion($_POST['NOMREUNION']);
            $reunion->setDateReunion($_POST['DATEREUNION']);
            $reunion->setIdLieu($_POST['IDLIEU']);
            $oPDO= new PdoReunion();
            $oPDO->create($reunion);
            break;
	case "lister":
            $oPDO = new PdoReunion();
            $lesReunions = $oPDO->readAll(); //ligne est un array contenant toutes les situations
            include("./page/reunion/lister.php");
            break;
        case "modifier":
            include("./page/reunion/modifier.php");
            break;
        case "traitement_modif":
            $reunion = new Reunion();
            $reunion->setIdReunion($_POST['IDREUNION']);
            $reunion->setNomReunion($_POST['NOMREUNION']);
            $reunion->setDateReunion($_POST['DATEREUNION']);
            $reunion->setIdLieu ($_POST['IDLIEU']);
            
            $pdo = new PdoReunion();
            $pdo->update($reunion);
            break;
        case "supprimer":
            $reunion = new Reunion();
            $reunion->setIdReunion($_GET['IDREUNION']);
            $oPDO = new PdoReunion();
            $oPDO->delete($reunion);
            break;
}